<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class ConsultasController extends CActiveRecord {

    public $usuario;
    public $clave;

    public function actionConsultas() {
        $model = $this->consultaUsuarioClave();
        $res = array();
        foreach ($model as $key => $val) {
            $res[] = array('username' => $key, 'value' => $val);
        }
        $this->render('consultas', array('resultados' => $res));
    }

    public function consultaUsuarioClave() {
        $connection = Yii::app()->db;
        $sql = "SELECT username, password FROM tbl_user";
        $consulta = $connection->createCommand($sql)->queryRow();
        return array('datos' => $consulta);
    }
}
